//
//  RadioDetailContactViewController.m
//  SuiRan
//
//  Created by lanou3g on 15-4-29.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "RadioDetailContactViewController.h"
#import "RadioDetail.h"
#import "RadioDetailListTableViewController.h"
#import "RadioWebViewController.h"
#import "AVPlayerViewController.h"
#import "playInfo.h"



@interface RadioDetailContactViewController ()<UIScrollViewDelegate>


@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIPageControl *pageControl;

@end

@implementation RadioDetailContactViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.scrollView = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 66. / 667 * kScreenHeight, kScreenWidth, kScreenHeight - 66. / 667 * kScreenHeight)] autorelease];
    self.pageControl = [[UIPageControl new] autorelease];
    
    
    _scrollView.delegate = self;
    _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width * 2, _scrollView.frame.size.height);
    _scrollView.backgroundColor = [UIColor whiteColor];
    _scrollView.pagingEnabled = YES;
    
    
    // 控制是否显示方向的滚动条
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    
    // 设置在scrollView上的视图不乱动
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:_scrollView];
    
    
    
        // 创建音乐播放页面
        AVPlayerViewController *aVC = [[AVPlayerViewController new] autorelease];
        aVC.tingid2 = _tingid0;
        aVC.playerTitle = _title1;
    
        aVC.view.frame = CGRectMake(0, 0, _scrollView.frame.size.width, _scrollView.frame.size.height);
        aVC.view.backgroundColor = [UIColor whiteColor];
        [_scrollView addSubview:aVC.view];
        [self addChildViewController:aVC];
    
//    // 创建音乐播放页面
//    AVPlayerViewController *aVC = [[AVPlayerViewController new] autorelease];
//    aVC.tingid2 = _tingid0;
//    aVC.playerTitle = _radioDetail.title;
//    NSLog(@"@@@@@@@@@@@@@%@", _radioDetail.title);
//    aVC.view.frame = CGRectMake(0, 0, _scrollView.frame.size.width, _scrollView.frame.size.height);
//    aVC.view.backgroundColor = [UIColor whiteColor];
//    [_scrollView addSubview:aVC.view];
//    [self addChildViewController:aVC];
    
    
    // 创建文章页面
    RadioWebViewController *rwVC = [[RadioWebViewController new] autorelease];
    rwVC.tingid = _tingid0;
    rwVC.view.frame = CGRectMake(kScreenWidth, -44. / 667 * kScreenHeight, _scrollView.frame.size.width, _scrollView.frame.size.height);
    rwVC.view.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:rwVC.view];
    [self addChildViewController:rwVC];
    
    
    
    //    // 创建音乐播放列表页面 (去除！！！！！)
    //    RadioDetailListTableViewController *rdlTVC = [[RadioDetailListTableViewController new] autorelease];
    //#pragma mark 传值
    //    rdlTVC.getDataArray2 = _getDataArray;
    //    rdlTVC.getUnameArray2 = _getUnameArray;
    //    rdlTVC.tingid = _tingid0;
    //
    //    rdlTVC.view.frame = CGRectMake(2 * kScreenWidth, 0, _scrollView.frame.size.width, _scrollView.frame.size.height);
    //    rdlTVC.view.backgroundColor = [UIColor whiteColor];
    //    [_scrollView addSubview:rdlTVC.view];
    //
    //    [self addChildViewController:rdlTVC];
    
    
    
    
    
    _pageControl = [[[UIPageControl alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(kScreenBounds) - 30./ 667 * kScreenHeight, CGRectGetWidth(kScreenBounds), 20. / 667 * kScreenHeight)] autorelease];
    _pageControl.numberOfPages = 2;
    _pageControl.currentPage = 0;
    [self.view addSubview:_pageControl];
    
    [_pageControl addTarget:self action:@selector(pageControlAction:) forControlEvents:UIControlEventValueChanged];
    
    
//    NSLog(@"%@", self.childViewControllers[0]);
}






- (void)pageControlAction:(UIPageControl *)sender
{
    CGPoint offset = CGPointMake(sender.currentPage * _scrollView.frame.size.width, 0);
    [_scrollView setContentOffset:offset animated:YES];
}



- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    _pageControl.currentPage = scrollView.contentOffset.x / scrollView.frame.size.width;
}







- (void)dealloc
{
    [_radioDetail release];
    [_getDataArray release];
    [_getUnameArray release];
    [_tingid0 release];
    [_scrollView release];
    [_title1 release];
    [super dealloc];
}


@end
